/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIPlanDeMovilizacionDespacho.java
 *
 * Created on 17/11/2011, 02:25:35 AM
 */
package GUI.Procesamiento;

import BE.BEContacto;
import BE.BEDespacho;
import BE.BEInternamiento;
import BE.BELineaDespacho;
import BL.BLDespacho;
import BL.BLGraspDespacho;
import java.util.List;
import java.util.ArrayList;
import BE.BENodoDespacho;
import BL.BLGrafoAlmacen;
import BL.BLAlmacen;
import BE.BEPallet;
import BE.BENodo;
import BL.BLGRASP;
import BL.BLmovimiento;
import BL.BLCardex;
import BL.BLPosicionxrack;
import BE.BELineaCardex;
import BE.BEPosicionxRack;
import java.sql.Timestamp;
import GUIalmacen.VentanaPrincipal;
import BL.BLTwoOptDespacho;
import javax.swing.JOptionPane;
import BL.BLPallet;

import GUIalmacen.almacen2;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JasperViewer;
/**
 *
 * @author Elessar
 */
public class GUIPlanDeMovilizacionDespacho extends javax.swing.JDialog {
    
    BEContacto objcontacto;
    List<BELineaDespacho> listapedido;
    BLGraspDespacho blGrasp;
    BLTwoOptDespacho blTwoOpt;
    BLDespacho blDespacho;
    BLGrafoAlmacen blGrafoAlmacen;
    BLAlmacen blAlmacen;
    List<BEPallet> lstPalletDespacho;
    BLCardex blCardex;
    
    List<BENodo> lstRuta;
    List<BENodo> lstPosicionDespacho;
    List<BENodo> rutaSolucion;
    
    String rutaTexto;


    /** Creates new form GUIPlanDeMovilizacionDespacho */
    public GUIPlanDeMovilizacionDespacho(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
         this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
    }


    public GUIPlanDeMovilizacionDespacho(java.awt.Frame parent, boolean modal, BEContacto objcontacto, List<BELineaDespacho> listapedido) {
        super(parent, modal);
        initComponents();
         this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
        
        blCardex = new BLCardex();
        this.objcontacto=objcontacto;
        
        this.listapedido=listapedido;
        blDespacho = new BLDespacho(listapedido);
        blDespacho.getProductosObligatorios();
        blDespacho.generarGrafo();
        
        blAlmacen = new BLAlmacen();
        blGrafoAlmacen = new BLGrafoAlmacen(blAlmacen.getAncho(),blAlmacen.getLargo());
        blGrafoAlmacen.cargarRacks();
        //blGrafoAlmacen.getBeGrafoAlmacen().imprimeGrafo();
        
        this.btnVisualizar.setEnabled(false);
        this.btnImprimir.setEnabled(false);
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        txtAreaSolucion = new javax.swing.JTextArea();
        btnAceptar1 = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        pnlGeneracion = new javax.swing.JPanel();
        lblGenerar = new javax.swing.JLabel();
        btnEjecutar = new javax.swing.JButton();
        btnVisualizar = new javax.swing.JButton();
        btnImprimir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Procesar Despacho");

        txtAreaSolucion.setColumns(20);
        txtAreaSolucion.setRows(5);
        jScrollPane2.setViewportView(txtAreaSolucion);

        btnAceptar1.setText("Guardar");
        btnAceptar1.setMaximumSize(new java.awt.Dimension(100, 25));
        btnAceptar1.setMinimumSize(new java.awt.Dimension(100, 25));
        btnAceptar1.setPreferredSize(new java.awt.Dimension(100, 25));
        btnAceptar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptar1ActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        pnlGeneracion.setBorder(javax.swing.BorderFactory.createTitledBorder("Generación"));

        lblGenerar.setText("Generando plan de movilización...");

        btnEjecutar.setText("Ejecutar");
        btnEjecutar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnEjecutar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnEjecutar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnEjecutar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEjecutarActionPerformed(evt);
            }
        });

        btnVisualizar.setText("Visualizar");
        btnVisualizar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnVisualizar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnVisualizar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnVisualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVisualizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlGeneracionLayout = new javax.swing.GroupLayout(pnlGeneracion);
        pnlGeneracion.setLayout(pnlGeneracionLayout);
        pnlGeneracionLayout.setHorizontalGroup(
            pnlGeneracionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlGeneracionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblGenerar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
                .addComponent(btnEjecutar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnVisualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlGeneracionLayout.setVerticalGroup(
            pnlGeneracionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlGeneracionLayout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addGroup(pnlGeneracionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlGeneracionLayout.createSequentialGroup()
                        .addComponent(lblGenerar)
                        .addGap(31, 31, 31))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlGeneracionLayout.createSequentialGroup()
                        .addGroup(pnlGeneracionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnVisualizar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnEjecutar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())))
        );

        btnImprimir.setText("Imprimir");
        btnImprimir.setMaximumSize(new java.awt.Dimension(100, 25));
        btnImprimir.setMinimumSize(new java.awt.Dimension(100, 25));
        btnImprimir.setPreferredSize(new java.awt.Dimension(100, 25));
        btnImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                    .addComponent(pnlGeneracion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btnImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnAceptar1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlGeneracion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAceptar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAceptar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptar1ActionPerformed
        // TODO add your handling code here:
        BLmovimiento blMovimiento = new BLmovimiento();
        blMovimiento.generarMov(this.lstPalletDespacho,this.objcontacto);  
        //System.out.println("guarda despacho");
        //almaceno la poscicion del Rack
        String accion="Registro de Despacho de Pallets: ";
        
        BLPosicionxrack objGestorPosRack = new BLPosicionxrack();
        
        for (int i=0; i<lstPalletDespacho.size(); i++){

            BEPosicionxRack objPosAux = lstPalletDespacho.get(i).getPosicionxrack();
            objGestorPosRack.liberarPosicion(objPosAux);
            System.out.println("libera posicion");
            BELineaCardex auxLineaCardex = new BELineaCardex();
            
            blCardex.cargarCardexProducto(lstPalletDespacho.get(i).getProducto().getIdProducto());
            auxLineaCardex.setIdProducto(lstPalletDespacho.get(i).getProducto().getIdProducto());

            java.util.Date today = new java.util.Date();
            Timestamp fecha = new Timestamp(today.getTime());


            auxLineaCardex.setFecha(fecha);
            auxLineaCardex.setCantSalida(lstPalletDespacho.get(i).getCantidad());
            auxLineaCardex.setCantIngreso(0);
            auxLineaCardex.setDetalle("DESPACHO.");
            auxLineaCardex.set0rigen(lstPalletDespacho.get(i).getPosicionxrack().getIdposicionxrack());
            auxLineaCardex.setDestino(0);

            auxLineaCardex.setTotalAlmacen(blCardex.obtenerExistencias());

            blCardex.guardarDespacho(auxLineaCardex,lstPalletDespacho.get(i).getIdPallet());
            
            accion=accion+lstPalletDespacho.get(i).getIdPallet()+",";
            
            //System.out.println("guarda cardex");
            
//            BLPallet blPallet = new BLPallet();
//            blPallet.limpiarPosicion(lstPalletDespacho.get(i).getIdPallet());
        }
        
            BL.BLLogAudit objGestorLog= new BL.BLLogAudit();
            BE.BELogAudit auxLogAudit= new BE.BELogAudit();
            auxLogAudit.setIdInterface(0);
            auxLogAudit.setIdUsuario(BL.BLCardex.getObjUsuario().getIdUsuario());
            
            
           
            accion=accion+"por el usuario "+BL.BLCardex.getObjUsuario().getUsuario()+".";
            auxLogAudit.setAccion(accion);
            java.util.Date aux= new java.util.Date();
            java.sql.Timestamp fecha= new java.sql.Timestamp(aux.getTime());
            
            auxLogAudit.setFecha(fecha);
            
            objGestorLog.registrarAccion(auxLogAudit);


        
        
        
        
        
        JOptionPane.showMessageDialog(null,"Despacho registrado","Informacion",JOptionPane.INFORMATION_MESSAGE);
        
        this.dispose();
    }//GEN-LAST:event_btnAceptar1ActionPerformed

    private void btnVisualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVisualizarActionPerformed
        // TODO add your handling code here:
        try{
           almacen2 frmVisualizarAlmacen = new almacen2();
           frmVisualizarAlmacen.dibujaruta(rutaSolucion, lstPosicionDespacho);
           frmVisualizarAlmacen.setTextRuta(txtAreaSolucion.getText());
        }
        catch(IOException ex){
            Logger.getLogger(GUIPlanDeMovilizacionDespacho.class.getName()).log(Level.SEVERE, null, ex);
        }  
        
    }//GEN-LAST:event_btnVisualizarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnEjecutarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEjecutarActionPerformed
        // TODO add your handling code here:
        blGrasp = new BLGraspDespacho(blDespacho.getObligatorios(), blDespacho.getGrafo());
        ArrayList<BENodoDespacho> nodosDespacho = blGrasp.run(0.3, 1000);
        //optimizacion TwoOpt de nodosDespacho  
        blTwoOpt = new BLTwoOptDespacho(blGrafoAlmacen);
        
        if (nodosDespacho.size()>3)
            nodosDespacho = blTwoOpt.run(nodosDespacho);
        
        if (nodosDespacho.get(0).getIdNodo()==0){
            nodosDespacho.remove(0);
        }
        lstPalletDespacho = blDespacho.getPalletsDespacho(nodosDespacho);                
                        
        //ArrayList<Integer> obligatorios = blGrafoAlmacen.calcularObligatorios(palletsDespacho);
        ArrayList<Integer> obligatorios = blGrafoAlmacen.calcularObligatorios(lstPalletDespacho);        
        //List<BENodo> grafo = blGrafoAlmacen.getBeGrafoAlmacen().getGrafo();
        System.out.println("Obligatorios:");
        for (int i=0; i<obligatorios.size(); i++){
            System.out.println("Nodo:"+obligatorios.get(i));
        }
        rutaSolucion = new ArrayList<BENodo>();
        for (int i=0; i<obligatorios.size(); i++){
//            int x=nodosDespacho.get(i).getX();
//            int y=nodosDespacho.get(i).getY();
            //rutaSolucion.add(new BENodo(blGrafoAlmacen.getIdNodoXY(x,y),x,y));
            rutaSolucion.add(blGrafoAlmacen.getBeGrafoAlmacen().getGrafo().get(obligatorios.get(i)-1));
        }
        System.out.println("Ruta Obligatorios:");
        for (int i=0; i<rutaSolucion.size(); i++){
            System.out.println("Nodo:"+rutaSolucion.get(i).getIdNodo()+" x:"+rutaSolucion.get(i).getX()+" y:"+rutaSolucion.get(i).getY());
        }
//        BLGRASP blGRASP = new BLGRASP (grafo.size(),obligatorios.size(),obligatorios,grafo);
//        //Ruta en el GrafoAlmacen
//        List<BENodo> rutaSolucion = blGRASP.run(0.3, 1000);
        rutaSolucion=blGrafoAlmacen.generarRutaAlmacen(rutaSolucion);
        
        //lstPosicionDespacho = blGrafoAlmacen.getNodosDespachoImpresionDePallet(lstPalletDespacho);
        
        System.out.println("Ruta Completa:");
        for (int i=0; i<rutaSolucion.size(); i++){
            System.out.println("Nodo:"+rutaSolucion.get(i).getIdNodo()+" x:"+rutaSolucion.get(i).getX()+" y:"+rutaSolucion.get(i).getY());
        }
        String text = blGrafoAlmacen.imprimeRuta(rutaSolucion, obligatorios, "Despachar");
        int rutaActual=rutaSolucion.size()-1;
        this.lstRuta=rutaSolucion;
        this.lstPosicionDespacho=blGrafoAlmacen.getNodosDespachoImpresion(nodosDespacho);
        
        text="Distancia: "+rutaActual+"\n"+text;
        rutaTexto=text;
        
        txtAreaSolucion.setText(text+blGrafoAlmacen.imprimirPallets(lstPalletDespacho));
        txtAreaSolucion.setEditable(false);
        
        this.btnImprimir.setEnabled(true);
        this.btnVisualizar.setEnabled(true);
        
    }//GEN-LAST:event_btnEjecutarActionPerformed

private void btnImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirActionPerformed
    
    LinkedList<BEDespacho> listaDespachos = new LinkedList<BEDespacho>();
    
    for(BEPallet detDespacho:lstPalletDespacho){
         listaDespachos.add(new BEDespacho(detDespacho.getProducto().getNombre(),detDespacho.getIdPallet(),detDespacho.getPosicionxrack().getIdrack(),detDespacho.getPosicionxrack().getIdzona(),
                detDespacho.getPosicionxrack().getFila(),detDespacho.getPosicionxrack().getColumna(),detDespacho.getCantidad()));
    } 
   
    
    Map parameters = new HashMap(); 
    parameters.put("cliente",this.objcontacto.getNombEmpresa()); 
    parameters.put("telefono",this.objcontacto.getTelefono()); 
    parameters.put("direccion",this.objcontacto.getDireccion()); 
    parameters.put("rutaTexto",rutaTexto.toString()); 
    try
    {
        JasperReport reporte = (JasperReport) JRLoader.loadObject("reporteDespacho.jasper");
        JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parameters, new JRBeanCollectionDataSource(listaDespachos));
        JRExporter exporter = new JRPdfExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        //exporter.setParameter(JRExporterParameter.OUTPUT_FILE, new java.io.File("reporteInternamientoEnPdf.pdf"));
        //exporter.exportReport();
        JasperViewer jviewer = new JasperViewer(jasperPrint,false); 
        jviewer.show();
        
        
        }
    catch(JRException e)
    {
    e.printStackTrace();
    }
    
    
    // TODO add your handling code here:
}//GEN-LAST:event_btnImprimirActionPerformed
    
    /**
     * @param args the command line arguments
     */
    

public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUIPlanDeMovilizacionDespacho.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUIPlanDeMovilizacionDespacho.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUIPlanDeMovilizacionDespacho.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUIPlanDeMovilizacionDespacho.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                GUIPlanDeMovilizacionDespacho dialog = new GUIPlanDeMovilizacionDespacho(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptar1;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEjecutar;
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnVisualizar;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblGenerar;
    private javax.swing.JPanel pnlGeneracion;
    private javax.swing.JTextArea txtAreaSolucion;
    // End of variables declaration//GEN-END:variables
}
